package com.tudouji.project.quality.controller;

import com.tudouji.common.utils.poi.ExcelUtil;
import com.tudouji.framework.aspectj.lang.annotation.Log;
import com.tudouji.framework.aspectj.lang.enums.BusinessType;
import com.tudouji.framework.web.controller.BaseController;
import com.tudouji.framework.web.domain.AjaxResult;
import com.tudouji.framework.web.page.TableDataInfo;
import com.tudouji.project.quality.domain.Qaitems;
import com.tudouji.project.quality.service.IQaitemsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 质检项管理Controller
 * 
 * @author wf
 * @date 2021-03-10
 */
@RestController
@RequestMapping("/quality/qaitems")
public class QaitemsController extends BaseController
{
    @Autowired
    private IQaitemsService qaitemsService;

    /**
     * 查询质检项管理列表
     */
    @PreAuthorize("@ss.hasPermi('quality:qaitems:list')")
    @GetMapping("/list")
    public TableDataInfo list(Qaitems qaitems)
    {
        startPage();
        List<Qaitems> list = qaitemsService.selectQaitemsList(qaitems);
        return getDataTable(list);
    }

    /**
     * 导出质检项管理列表
     */
    @PreAuthorize("@ss.hasPermi('quality:qaitems:export')")
    @Log(title = "质检项管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Qaitems qaitems)
    {
        List<Qaitems> list = qaitemsService.selectQaitemsList(qaitems);
        ExcelUtil<Qaitems> util = new ExcelUtil<Qaitems>(Qaitems.class);
        return util.exportExcel(list, "qaitems");
    }

    /**
     * 获取质检项管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('quality:qaitems:query')")
    @GetMapping(value = "/{guid}")
    public AjaxResult getInfo(@PathVariable("guid") String guid)
    {
        return AjaxResult.success(qaitemsService.selectQaitemsById(guid));
    }

    /**
     * 新增质检项管理
     */
    @PreAuthorize("@ss.hasPermi('quality:qaitems:add')")
    @Log(title = "质检项管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Qaitems qaitems)
    {
        return toAjax(qaitemsService.insertQaitems(qaitems));
    }

    /**
     * 修改质检项管理
     */
    @PreAuthorize("@ss.hasPermi('quality:qaitems:edit')")
    @Log(title = "质检项管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Qaitems qaitems)
    {
        return toAjax(qaitemsService.updateQaitems(qaitems));
    }

    /**
     * 删除质检项管理
     */
    @PreAuthorize("@ss.hasPermi('quality:qaitems:remove')")
    @Log(title = "质检项管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{guids}")
    public AjaxResult remove(@PathVariable String[] guids)
    {
        return toAjax(qaitemsService.deleteQaitemsByIds(guids));
    }
}
